<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Globalize::DbViewTranslator</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Globalize::DbViewTranslator</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/vendor/plugins/globalize/lib/globalize/localization/db_view_translator_rb.html">
                vendor/plugins/globalize/lib/globalize/localization/db_view_translator.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Object
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000065">cache_count</a>&nbsp;&nbsp;
      <a href="#M000066">cache_reset</a>&nbsp;&nbsp;
      <a href="#M000067">new</a>&nbsp;&nbsp;
      <a href="#M000064">set_pluralized</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name">Singleton</span>
      </div>
    </div>

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">cache_size</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">cache_total_hits</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">cache_total_queries</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">max_cache_size</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc">
The maximum size of the cache in kilobytes. This is just a rough estimate,
the cache can grow bigger than this figure.

</td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000067" class="method-detail">
        <a name="M000067"></a>

        <div class="method-heading">
          <a href="#M000067" class="method-signature">
          <span class="method-name">new</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000067-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000067-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/globalize/lib/globalize/localization/db_view_translator.rb, line 120</span>
120:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
121:         <span class="ruby-ivar">@cache</span> = {}
122:         <span class="ruby-ivar">@cache_size</span> = <span class="ruby-value">0</span>
123:         <span class="ruby-ivar">@cache_total_hits</span> = <span class="ruby-value">0</span>
124:         <span class="ruby-ivar">@cache_total_queries</span> = <span class="ruby-value">0</span>
125: 
126:         <span class="ruby-comment cmt"># default cache size is 8mb</span>
127:         <span class="ruby-ivar">@max_cache_size</span> = <span class="ruby-value">8192</span>
128:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000065" class="method-detail">
        <a name="M000065"></a>

        <div class="method-heading">
          <a href="#M000065" class="method-signature">
          <span class="method-name">cache_count</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the number of items in the cache.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000065-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000065-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/globalize/lib/globalize/localization/db_view_translator.rb, line 58</span>
58:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cache_count</span>
59:       <span class="ruby-ivar">@cache</span>.<span class="ruby-identifier">size</span>
60:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000066" class="method-detail">
        <a name="M000066"></a>

        <div class="method-heading">
          <a href="#M000066" class="method-signature">
          <span class="method-name">cache_reset</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Resets the cache and its statistics &#8212; for testing.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000066-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000066-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/globalize/lib/globalize/localization/db_view_translator.rb, line 63</span>
63:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cache_reset</span>
64:       <span class="ruby-identifier">cache_clear</span>
65:       <span class="ruby-ivar">@cache_total_hits</span> = <span class="ruby-value">0</span>
66:       <span class="ruby-ivar">@cache_total_queries</span> = <span class="ruby-value">0</span>
67:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000064" class="method-detail">
        <a name="M000064"></a>

        <div class="method-heading">
          <a href="#M000064" class="method-signature">
          <span class="method-name">set_pluralized</span><span class="method-args">(key, language, idx, translation, namespace = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000064-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000064-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/globalize/lib/globalize/localization/db_view_translator.rb, line 43</span>
43:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_pluralized</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">language</span>, <span class="ruby-identifier">idx</span>, <span class="ruby-identifier">translation</span>, <span class="ruby-identifier">namespace</span> = <span class="ruby-keyword kw">nil</span>)
44:       <span class="ruby-identifier">invalidate_cache</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">language</span>, <span class="ruby-identifier">idx</span>, <span class="ruby-identifier">namespace</span>)
45:       <span class="ruby-constant">ViewTranslation</span>.<span class="ruby-identifier">transaction</span> <span class="ruby-keyword kw">do</span>
46:         <span class="ruby-identifier">old_tr</span> = <span class="ruby-constant">ViewTranslation</span>.<span class="ruby-identifier">pick</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">language</span>, <span class="ruby-identifier">idx</span>, <span class="ruby-identifier">namespace</span>)
47:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">old_tr</span>
48:           <span class="ruby-identifier">old_tr</span>.<span class="ruby-identifier">update_attribute</span>(<span class="ruby-identifier">:text</span>, <span class="ruby-identifier">translation</span>)
49:         <span class="ruby-keyword kw">else</span>
50:           <span class="ruby-constant">ViewTranslation</span>.<span class="ruby-identifier">create!</span>(<span class="ruby-identifier">:tr_key</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">key</span>,
51:             <span class="ruby-identifier">:language_id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">language</span>.<span class="ruby-identifier">id</span>, <span class="ruby-identifier">:pluralization_index</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">idx</span>,
52:             <span class="ruby-identifier">:text</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">translation</span>, <span class="ruby-identifier">:namespace</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">namespace</span>)
53:         <span class="ruby-keyword kw">end</span>
54:       <span class="ruby-keyword kw">end</span>
55:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>